use xiaohao_ar::bit_operation_ar::*;

// 1.
#[test]
fn sum_nums_test() {
    let n = 5;
    assert_eq!(15, sum_nums(n));
}

// 2.
#[test]
fn is_pow_of_two_test() {
    let n = 16;
    assert_eq!(true, is_pow_of_two(n));
    let n1 = 124;
    assert_eq!(false, is_pow_of_two(n1));
}

// 3.
#[test]
fn hamming_weight_test() {
    let n: u32 = 21;
    assert_eq!(3, hamming_weight(n));
}
// 3.1
#[test]
fn hamming_weight_v2_test() {
    let n: u32 = 31;
    assert_eq!(5, hamming_weight_v2(n));
}

// 4.
#[test]
fn single_number_test() {
    let v1: Vec<u32> = vec![4, 1, 2, 1, 2];
    assert_eq!(4, single_number(v1));
}
// 4.1
#[test]
fn single_number_v2_test() {
    let v1: Vec<u32> = vec![1, 1, 1, 2, 3, 3, 3];
    assert_eq!(2, single_number_v2(v1));
}
// 4.2
#[test]
fn single_number_v3_test() {
    let v1: Vec<u32> = vec![1, 1, 1, 3, 4, 4, 4];
    assert_eq!(3, single_number_v3(v1));
}
// 4.3
#[test]
fn single_number_v4_test() {
    let v1: Vec<u32> = vec![1, 1, 1, 3, 3, 4, 3];
    assert_eq!(4, single_number_v4(v1));
}

// 5.
#[test]
fn missing_number_test() {
    let v1: Vec<u32> = vec![0, 1, 2, 4];
    assert_eq!(3, missing_number(v1));
}